use crate::test_rc::List::{Cons, Nil};

use std::rc::Rc;


enum List {
    Cons(i32, Rc<List>),

    Nil,
}


// use crate::


/*

3

    a-> 5----->10--------->Nil

4
*/

#[test]
fn test1() {
    let a = Rc::new(Cons(5, Rc::new(Cons(10, Rc::new(Nil)))));


    println!("rc count is {}", Rc::strong_count(&a));
    let b = Cons(3, Rc::clone(&a));


    println!("rc count is {}", Rc::strong_count(&a));

    {
        let c = Cons(4, Rc::clone(&a));
        println!("rc count is {}", Rc::strong_count(&a));

        //  离开作用域   自动减1
    }

    println!("rc count is {}", Rc::strong_count(&a));
}











